﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using AmazeUI.db;
using Dbx.web.Models.XtModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Am.Test
{
    [TestClass]
    public class Baoming
    {
          int zuowei(int i)
        {
            if (i>20)
            {
                return zuowei(i - 20);
            }
            else
            {
                return i;
            }
        }
          int pai(int i)
          {
              if ((i % 20)==0)
              {
                  return ((i/20) );
              }
              else
              {
                  return ((i/20) + 1);
              }
            
          }

          int[] zuowei2(int num)
          {
              for (int i = 0; i < w.Length; i++)
              {
                  if (num > w[i] && num <= w[i+1])
                  {
                      return new[] { i + 1, num - w[i] };
                  }
              }
              return null;

          }
         
          XtEntities db = new XtEntities();

        private int[] w =   {0,7, 14,21,28,39,51,63,75,87,99,111,124,137,150,163,176};
        [TestMethod]
        public void editzuowei()
        {
            IQueryable<Goods> queryable = db.Goods.Where(a => a.BodyContent != null&&a.NoClass>340);

            foreach (var item in queryable)
            {
                this.db.Goods.Remove(item);
            }
            this.db.SaveChanges();
        }



        [TestMethod]
        public void addzuowei()
        { 
            List<SubGoods> sgs=new List<SubGoods>();
            for (int i = 1; i < 177; i++)
            {
                SubGoods model = new SubGoods();
                model.Body = "年会报名";
                model.GoodsClassId = 2;
                       
                var  z = zuowei2(i);
                model.BodyContentmin = string.Format("3-{0}-1-{1}", +z[0], z[1]);
                model.Returl = "http://hd.jjck.cn/dbx/bmquery";
                model.Nourl = "http://hd.jjck.cn/dbx/jsnotify";
                model.BodyContent = string.Format("C区{0}排{1}号", +z[0], z[1]);
                model.Price = 10000;
                model.NoClass = i+340+176;
             
                // sgs.Add(model);
                Goods goods = new Goods(model);
                 db.Goods.Add(goods);
            }
              db.SaveChanges();
            //foreach (var item in sgs)
            //{
            //    Debug.WriteLine(item.BodyContentmin);
            //}

        }
    }
}